<?php

namespace app\admin\controller;

use think\Controller;
use app\admin\model\AdminMenus;
use app\admin\model\Sysconfigs;
use tools\AdminAuth;
use tools\Tree;

use think\Request;
use think\Session;
use app\admin\model\AdminUsers;

class Base extends Controller
{

    protected $request;
    protected $requestType;
    protected $param;

    protected $webData;
    protected $id;

    protected $module;
    protected $controller;
    protected $action;
    protected $url;

    protected $uid = 0;
    protected $needAuth = true;

    protected $showLeftMenu = true;
    protected $showDataHeader = true;
    protected $showDataHeaderAddButton = true;
    protected $showDataHeaderDeleteButton = true;

    protected $showFormHeader = true;
    protected $showFormHeaderBackButton = true;

    protected $showFormFooter = true;
    protected $showFormFooterSubmitButton = true;
    protected $showFormFooterResetButton = true;

    public function __construct()
    {
        $this->request     = Request::instance();
        $this->param      = $this->request->param();
        $this->module     = $this->request->module();
        $this->controller = $this->request->controller();
        $this->action     = $this->request->action();

        $this->id = isset($this->param['id']) ? $this->param['id'] : -1;

        $this->url = parse_name($this->module) .
            '/' . parse_name($this->controller) .
            "/" . parse_name($this->action);

        parent::__construct();
    }

    public function _initialize()
    {
        $this->uid = Session::get('user.id');
        $menu_info              = AdminMenus::get(['url' => $this->url]);
        $this->webData['title'] = $menu_info['title'];
        //用户信息
        $user_info = AdminUsers::get($this->uid);

        $this->webData['user_info'] = $user_info;
        //分页记录数处理
                            $this->webData['list_rows'] = get_list_rows();
        $this->assign(['webData' => $this->webData]);
        $this->assign([
            'showDataHeader'             => $this->showDataHeader,
            'showDataHeaderAddButton'    => $this->showDataHeaderAddButton,
            'showDataHeaderDeleteButton' => $this->showDataHeaderDeleteButton,
            'showFormHeader'             => $this->showFormHeader,
            'showFormHeaderBackButton'   => $this->showFormHeaderBackButton,
            'showFormFooter'             => $this->showFormFooter,
            'showFormFooterSubmitButton' => $this->showFormFooterSubmitButton,
            'showFormFooterResetButton'  => $this->showFormFooterResetButton,
        ]);

        parent::_initialize(); // TODO: Change the autogenerated stub
    }

}